package bimvu.lab21;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.TextView;

import java.util.ArrayList;


public class MainActivity extends Activity {

    private ImageView imageView;
    private TextView downloadedSizeTextView;
    private TextView averageSpeedTextView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        ListView urlListView = (ListView) findViewById(R.id.listView);

        final ArrayList<String> urlItems = new ArrayList<String>();
        urlItems.add("http://www.soft-v3.ru/images/stories/android_platform_256.png");
        urlItems.add("http://graphics8.nytimes.com/images/2013/10/13/magazine/mag-13WMT-t_CA0/mag-13WMT-t_CA0-superJumbo.png");
        urlItems.add("http://appsgames.ru/wp-content/uploads/2014/09/70e7025a05b674852b9f3cea0998259c.jpeg");
        urlItems.add("https://lh3.googleusercontent.com/-ILII73WeerE/AAAAAAAAAAI/AAAAAAAAA9w/R_osPa1slYE/photo.jpg");
        urlItems.add("http://www.icondesignlab.com/uploads/portfolio/thumbs/280_256x256_Avatar-design-in-android-style.png");

        final ArrayAdapter<String> urlListAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, urlItems);
        urlListView.setAdapter(urlListAdapter);

        final Context thisContext = this;
        urlListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
                String url = ((TextView) view).getText().toString();
                Intent intent = new Intent(thisContext, DownloadedContentActivity.class);
                intent.putExtra("url", url);
                startActivity(intent);
            }
        });
    }

}
